<%-- 
    Document   : login
    Created on : Jan 14, 2013, 2:01:37 PM
    Author     : Nero
--%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>CM2 Fashion Shop Admin</title>
        <link rel="stylesheet" type="text/css" href="Style/Admin/style.css" />
        <link rel="stylesheet" type="text/css" media="all" href="Style/Admin/niceforms-default.css" />
        
        <script type="text/javascript" src="Script/Admin/jquery.min.js"></script>
        <script type="text/javascript" src="Script/Admin/ddaccordion.js"></script>
        <script type="text/javascript">
            ddaccordion.init({
                headerclass: "submenuheader", //Shared CSS class name of headers group
                contentclass: "submenu", //Shared CSS class name of contents group
                revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
                mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
                collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
                defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
                onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
                animatedefault: false, //Should contents open by default be animated into view?
                persiststate: true, //persist state of opened contents within browser session?
                toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
                togglehtml: ["suffix", "<img src='Style/Admin/images/plus.gif' class='statusicon' />", "<img src='Style/Admin/images/minus.gif' class='statusicon' />"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
                animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
                oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
                    //do nothing
                },
                onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
                    //do nothing
                }
            })
        </script>
        <script type="text/javascript" src="Script/Admin/jconfirmaction.jquery.js"></script>
        <script type="text/javascript" src="Script/Admin/niceforms.js"></script>
        <script type="text/javascript" src="Script/jquery-1.8.2.js"></script>
        <script type="text/javascript">
            $(document).ready(function(){  
                $(".error_box_login").hide();
            })
            function doAjax() {	
                var username = $('#txtUsername').val();
                var password = $('#txtPassword').val();
                if(username == ""){
                    $(".error_box_login").show("slow");
                    $('.error_box_login').html("Xin nhập Tên Đăng Nhập");
                }
                else if(password == ""){
                    $(".error_box_login").show("slow");
                    $('.error_box_login').html("Xin nhập Mật Khẩu");
                }
                else{
                    $.ajax({
                        url: 'login.htm',
                        type: 'POST',
                        data: "username=" + username + "&password=" + password,
                        success: function(data) {
                            if(data == "NOT_EXIST")
                            {
                                $(".error_box_login").show("slow");
                                $('.error_box_login').html("Tài khoản không tồn tại");
                            }
                            else if(data == "WRONG_PASSWORD")
                            {
                                $(".error_box_login").show("slow");
                                $('.error_box_login').html("Sai mật khẩu");
                            } 
                            else if(data == "NOT_ALLOW")
                            {
                                $(".error_box_login").show("slow");
                                $('.error_box_login').html("Tài khoản của bạn không thể truy cập khu vực này");
                            }    
                            else if(data == "SUCCESS")
                            {
                                window.location = "/quanly.htm?view=quanlysanpham";
                            }
                            else
                            {
                                $(".error_box_login").show("slow");
                                $('.error_box_login').html("Lỗi kết nối. Xin thử lại sau khi reload trang");                                 
                            }
                        
                        },
                        error: function(data) {
                            $(".error_box_login").show("slow");
                            $('.error_box_login').html("Lỗi kết nối. Xin thử lại sau khi reload trang");                        
                        }                
                    });
                }
            }
        </script>
    </head>
    <body>
        <div id="main_container">
            <div class="header_login">
                <div class="logo"><a href="#"><img src="Style/Admin/images/logo.gif" alt="" title="" border="0" /></a></div>
            </div>
            <div class="login_form">
                <h3>Admin Panel Login</h3>
                <!--<a href="#" class="forgot_pass">Forgot password</a> -->
                <form action="" method="post" class="niceform">
                    <dl>
                        <dt><label for="email">Username:</label></dt>
                        <dd><input type="text" name="" id="txtUsername" size="54" /></dd>
                    </dl>
                    <dl>
                        <dt><label for="password">Password:</label></dt>
                        <dd><input type="password" name="" id="txtPassword" size="54" /></dd>
                    </dl>
                    <dl>
                        <div class="error_box_login" diplay="false">
                            Thông báo lỗi
                        </div>  
                    </dl>
                    <dl class="submit">                            
                        <input type="button" onclick="doAjax()" value="Đăng Nhập" />
                    </dl>
                </form>
            </div>  
            <div class="footer_login">
                <div class="left_footer_login">
                    CM2 Fashion Shop | Powered by <a href="http://indeziner.com">INDEZINER</a>
                </div>
                <div class="right_footer_login">
                    <a href="http://indeziner.com"><img src="Style/Admin/images/indeziner_logo.gif" alt="" title="" border="0" /></a>
                </div>
            </div>     
        </div>		
    </body>
</html>